package com.hxzy.controller;

import com.hxzy.common.util.DictDataUtil;
import com.hxzy.common.vo.DictData;
import com.hxzy.common.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author Administrator
 */
@Api(tags = "通用字典API")
@RestController
@RequestMapping(value = "/api/dict")
public class DictDataController {

    @ApiOperation(value = "根据键查询值")
    @GetMapping(value = "/bykey/{key}")
    public R findByKey(@PathVariable(value = "key") String key){
        List<DictData> byTag = DictDataUtil.getByTag(key);
        return R.okHasData(byTag);
    }


    @ApiOperation(value = "得到口味列表值")
    @GetMapping(value = "/flavorList")
    public R flavorList(){
        List<Map<String,Object>>  arr= new ArrayList<>();

        Map<String,Object>  data01=new HashMap<>();
        data01.put("name","辣度");
        data01.put("value", Arrays.asList("不辣","微辣","中辣","重辣"));
        arr.add(data01);

        Map<String,Object>  data02=new HashMap<>();
        data02.put("name","忌口");
        data02.put("value", Arrays.asList("不要葱","不要蒜","不要香菜","不要辣"));
        arr.add(data02);

        Map<String,Object>  data03=new HashMap<>();
        data03.put("name","温度");
        data03.put("value", Arrays.asList("热饮","常温","去冰","少冰","多冰"));
        arr.add(data03);

        Map<String,Object>  data04=new HashMap<>();
        data04.put("name","甜味");
        data04.put("value",  Arrays.asList("无糖","少糖","半糖","多糖","全糖"));
        arr.add(data04);

        return R.okHasData(arr);
    }
}
